package com.hankol.material.adapter

import android.text.TextUtils
import com.baselibrary.utils.GlideUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hankol.material.R
import com.baselibrary.bean.download.DownloadInfo
import com.baselibrary.bean.download.ShowUIUtils

/**下载完成  列表
 * @author: merbng
 * @time: 2021/10/15 10:33
 * @description:
 */
class TabDownloadCompleteAdapter : BaseQuickAdapter<DownloadInfo, BaseViewHolder>(R.layout.item_tab_download_complete) {

    override fun convert(helper: BaseViewHolder, item: DownloadInfo) {
        helper.setText(R.id.tv_name, "${item.fileName}")
        item.path?.let {
            helper.setText(R.id.tv_time, "${item.time}")
                    .setGone(R.id.img_video_play, item.type == 1)
        }
        helper.setText(R.id.tv_size, "${ShowUIUtils.byteToString(item.total.toDouble())}")
        GlideUtils.loadImg(mContext, R.drawable.ic_hankol_101, R.drawable.ic_hankol_101, if (!TextUtils.isEmpty(item.fileIcon)) item.fileIcon else item.url, helper.getView(R.id.img_cover))
        helper.addOnClickListener(R.id.tv_open)
        helper.addOnClickListener(R.id.img_del)
    }
}